package ir.sourcecodes.animalsounds;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;


import java.util.ArrayList;

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    ArrayList<Integer> arrayRandomFullPicAd = new ArrayList<>();
    private Context mContext;
    /* access modifiers changed from: private */
    public OnItemClickListener mItemClickListener;
    /* access modifiers changed from: private */
    public ArrayList<AbstractModel> modelList;

    public interface OnItemClickListener {
        void onItemClick(View view, int i, AbstractModel abstractModel);


    }

    public RecyclerViewAdapter(Context context, ArrayList<AbstractModel> arrayList) {
        this.mContext = context;
        this.modelList = arrayList;
    }

    public void updateList(ArrayList<AbstractModel> arrayList) {
        this.modelList = arrayList;
        notifyDataSetChanged();
    }

    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_recycler_list, viewGroup, false));
    }

    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int i) {
        if (viewHolder instanceof ViewHolder) {
            final AbstractModel item = getItem(i);
            ViewHolder viewHolder2 = (ViewHolder) viewHolder;
            viewHolder2.itemTxtTitle.setText(item.getTitle());
            viewHolder2.itemTxtMessage.setText(item.getMessage());
            viewHolder2.imgUser.setImageResource(G.resources.getIdentifier(item.getAnimalImageName(), "drawable", G.packageName));
            viewHolder2.itemTxtTitle.setTextSize(0, (float) (G.width / 22));
            viewHolder2.itemTxtMessage.setTextSize(0, (float) (G.width / 24));
            viewHolder2.itemTxtMessage.setTypeface(G.iranSansBold);
            viewHolder2.imgUser.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {

                  view.startAnimation(G.clickAnim);
                 G.app.playMp(item.getAnimalImageName().replace("p", "fa"), true);
                 switch (i){
                    case 3:
                    case 6:
                    case 9:
                    case 12:
                    case 15:
                    case 18:
                    case 21:
                    case 24:
                    case 27:
                    case 30:
                    case 33:
                    case 36:
                    case 39:
                    case 42:
                    case 45:
                    case 48:
                    case 51:
                    case 54:
                    case 57:
                    case 60:
                    case 63:
                    case 66:
                    case 69:
                    case 72:
                    case 75:
                    case 78:
                    case 81:
                    case 84:
                    case 87:
                    case 90:
                    case 93:
                    case 96:
                    case 99:
                    case 102:
                    case 105:
                    case 108:
                    case 111:
                        ads.init(mContext);
                        ads.showFull(mContext);
                        break;


                }
                }
            });
        }
    }

    public int getItemCount() {
        return this.modelList.size();
    }

    public void SetOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mItemClickListener = onItemClickListener;
    }

    private AbstractModel getItem(int i) {
        return this.modelList.get(i);
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        /* access modifiers changed from: private */
        public ImageView imgUser;
        /* access modifiers changed from: private */
        public TextView itemTxtMessage;
        /* access modifiers changed from: private */
        public TextView itemTxtTitle;

        public ViewHolder(final View view) {
            super(view);
            this.imgUser = (ImageView) view.findViewById(R.id.img_user);
            this.itemTxtTitle = (TextView) view.findViewById(R.id.item_txt_title);
            this.itemTxtMessage = (TextView) view.findViewById(R.id.item_txt_message);

         view.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 RecyclerViewAdapter.this.mItemClickListener.onItemClick(view, ViewHolder.this.getAdapterPosition(), (AbstractModel) RecyclerViewAdapter.this.modelList.get(ViewHolder.this.getAdapterPosition()));

             }
         });
        }
    }
}
